#include <regex>
#include <iostream>
#include <string>

int main()
{
   std::string url("GET /login?usrname=shr&passwd=12345 HTTP/1.0\r\n");
   // std::string url("GET /login HTTP/1.0\r\n");
   std::smatch sm;
   std::regex e("(GET|POST|HEAD|DELETE) ([^?]*)(?:\\?(.*))* HTTP/(1.[01])(?:\n|\r\n)");
   bool ret = std::regex_match(url, sm, e);
   if (!ret) { return -1; }
   for (auto& s : sm) {
      std::cout << s << std::endl;
   }
   return 0;
}
